package com.atguigu.activemq_learn.spring;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

/**
 * 整合spring，队列消息消费者
 */
@Service
public class SpringMQ_Queue_Consumer {

    @Autowired
    private JmsTemplate jmsTemplate;

    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        SpringMQ_Queue_Consumer cousumer = (SpringMQ_Queue_Consumer) applicationContext.getBean("springMQ_Queue_Consumer");
        String textMessage = (String) cousumer.jmsTemplate.receiveAndConvert();
        System.out.println("spring 接收到队列消息："+ textMessage);
    }

}
